//
//  HomeTableViewCell.m
//  CarCare
//
//  Created by ileo on 15/1/6.
//  Copyright (c) 2015年 baozun. All rights reserved.
//

#import "MessageTableViewCell.h"

#define CELL_HEIGHT (80 + (130 * __MAIN_RATIO_375))
#define BACK_VIEW_HEIGHT (71 + (130 * __MAIN_RATIO_375))
@interface MessageTableViewCell()

@property (nonatomic, strong) UIView * backView;
@property (nonatomic, strong) UILabel *titleL;
//@property (nonatomic, strong) UILabel *detailL;
@property (nonatomic, strong) UILabel *subTitltL;
@property (nonatomic, strong) UIImageView * imageV;

@end

@implementation MessageTableViewCell

+(CGFloat)getCellHeight{
    
    return CELL_HEIGHT;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.backgroundColor = [Theme backGroundColor];
        CGFloat backVIewY = 9;
        CGFloat backViewH = BACK_VIEW_HEIGHT;
        CGFloat backViewX = 10 * __MAIN_RATIO_375;
        CGFloat backViewW = __MAIN_WIDTH - backViewX * 2;
        
        CGFloat imageVH = 130 * __MAIN_RATIO_375;
        CGFloat titleLY = 13;
        CGFloat labelX = 12 * __MAIN_RATIO_375;
        CGFloat labelW = backViewW - labelX * 2;
        CGFloat labelH = 19;
        
        self.backView = [[[UIView viewWithFrame:CGRectMake(backViewX, backVIewY, backViewW, backViewH)] resetBackgroundColor:[UIColor whiteColor]] setupOnView:self];
        self.backView.layer.cornerRadius = 4;
        self.backView.layer.masksToBounds = YES;
        self.backView.layer.borderColor = [Theme lineColor].CGColor;
        self.backView.layer.borderWidth = 1;
        self.titleL = [Factory labelWithFrame:CGRectMake(labelX, titleLY, labelW , labelH) font:FONT_DEFAULT_Light(15) text:@"" textColor:[Theme wordColor] onView:self.backView textAlignment:NSTextAlignmentLeft];
            
        
        self.subTitltL = [Factory labelWithFrame:CGRectMake(labelX, self.titleL.bottom , labelW, labelH - 3) font:FONT_DEFAULT_Light(10) text:@"" textColor:[Theme wordGrayColor] onView:self.backView textAlignment:NSTextAlignmentLeft];
        
        self.imageV = [Factory imageViewWithFrame:CGRectMake(labelX, self.subTitltL.bottom + 10, labelW, imageVH) image:nil onView:self.backView];
        self.imageV.layer.borderWidth = 1;
        self.imageV.layer.borderColor = [Theme lineColor].CGColor;
        self.imageV.backgroundColor = [UIColor clearColor];
        self.imageV.contentMode = UIViewContentModeScaleToFill;
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

-(void)setModel:(AdverticePageModel *)model{
    _model = model;
    self.titleL.text = model.title;
    self.subTitltL.text = model.subTitle;
    
    [self.imageV setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",model.img]] placeholderImage:nil];
}

@end